home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 3 / BBS in a box - Trilogy III.iso / Files / Prog / L-M / mini / pace.c < prev    next >
Encoding:
C/C++ Source or Header  |  1987-09-26  |  2.4 KB  |  93 lines  |  [TEXT/MPS ]

  1. /*
  2.  *  This routine turns pacing on/off and gets a pace character
  3.  *  Author:Jerry LeVan 
  4.  *          325 Boone Trail
  5.  *            Richmond Ky 40475
  6.  *
  7.  *  New File: Sep 23,1987
  8.  */
  9.  
  10. #include <quickdraw.h>
  11. #include <controls.h>
  12. #include <dialogs.h>
  13.  
  14. #define PACEID 5088    /* dialog number */
  15. #define PACECHECK 3    /* item number for checkbox */
  16. #define PACECHAR  4    /* item number for edit item for pace char */
  17. #define PACEDELAY 6 /* item number for delay field */
  18. #define OK          1    /* item number for OK button */
  19.  
  20. #define __SEG__ Pacing
  21.  
  22.  void DoPaceDialog(theChar,doPacing,theDelay)
  23.  char *theChar;      /* current choice */
  24.  Boolean *doPacing; /* true implies do line pacing */
  25.  long *theDelay;    /* number of ticks to delay between characters */
  26.  
  27.  { DialogPtr theWindow;
  28.    Rect Box;
  29.    short type,item;
  30.    GrafPtr     savePort;
  31.    Handle ckHandle;        /* handle to check item */
  32.    Handle chHandle;        /* handle to pace character item */
  33.    Handle aHandle;        /* for ok button */
  34.    Handle deHandle;        /* handle for delay field */
  35.    char aString[10];     /* storage for pace character ,delay string */
  36.    
  37.    GetPort(&savePort);
  38.  
  39.    /* get the dialog (created invisible) */
  40.    theWindow = (DialogPtr)GetNewDialog(PACEID,0,(Ptr)-1);
  41.    SetPort(theWindow);
  42.  
  43.     /* set the current prompt character and pacing state */
  44.     
  45.     /* first set the check box with the appropriate value */
  46.     GetDItem(theWindow,PACECHECK,&type,&ckHandle,&Box);
  47.     SetCtlValue((ControlHandle)ckHandle,*doPacing);
  48.     
  49.     /* Now set the pace character */
  50.     GetDItem(theWindow,PACECHAR,&type,&chHandle,&Box);
  51.     aString[0] = *theChar;
  52.     aString[1] = (char)0;
  53.     SetIText(chHandle,aString);
  54.     SelIText(theWindow,PACECHAR,0,32767);
  55.     
  56.     /* set the delay amount field */
  57.     NumToString(*theDelay,aString);
  58.     GetDItem(theWindow,PACEDELAY,&type,&deHandle,&Box);
  59.     SetIText(deHandle,aString);
  60.     
  61.     /* outline the OK button */
  62.     GetDItem(theWindow,OK,&type,&aHandle,&Box);
  63.     PenSize(3,3);
  64.     InsetRect(&Box,-4,-4);
  65.     FrameRoundRect(&Box,16,16);
  66.     PenSize(1,1);
  67.     
  68.     /* show the window */
  69.     ShowWindow(theWindow);
  70.     
  71.     /* now we can do the dialog */
  72.     do
  73.      {  ModalDialog(0,&item);
  74.         if(item == PACECHECK){
  75.                /* invert the value */
  76.             *doPacing = !(*doPacing);
  77.             SetCtlValue((ControlHandle)ckHandle,*doPacing);
  78.            }
  79.      }
  80.     while(item!=OK);
  81.     
  82.     /* return the info left in the dialog */
  83.     
  84.     GetIText(chHandle,aString);
  85.     *theChar = aString[0];        /* the pace character */
  86.     
  87.     GetIText(deHandle,aString);
  88.     StringToNum(aString,theDelay);
  89.     
  90.     /* clean up and return */
  91.     DisposDialog(theWindow);
  92.     SetPort(savePort);
  93. }